package com.itcm.skymail.search.web;

import com.itcm.skymail.search.service.MallSearchService;
import com.itcm.skymail.search.vo.SearchParam;
import com.itcm.skymail.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.io.IOException;

/**
 * 描述:
 *
 * @author cm_fighting
 * @create 2020-10-21 3:46 下午
 */
@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;

    @GetMapping({"/", "/list.html"})
    public String listPage(SearchParam param, Model model) throws IOException {
        SearchResult searchResult = mallSearchService.search(param);
        model.addAttribute("searchResult", searchResult);
        System.out.println(searchResult);
        System.out.println(searchResult.getProducts());
        System.out.println(searchResult.getAttrs());
        return "list";
    }
}
